package com.lccviolet;

import lombok.Getter;

/**
 * @author LiChaochao
 * @Date 2021/9/9 16:18
 * @Description CountryEnum：CountDownLatchDemo案例中使用的枚举类
 *
 * 枚举：就像一个简易的数据库表
 */
public enum CountryEnum {
    ONE(1, "花"),
    TWO(2, "鸟"),
    THREE(3, "桥"),
    FOUR(4, "白"),
    FIVE(5, "七");

    @Getter
    private Integer retCode;
    @Getter
    private String retMessage;

    CountryEnum(Integer retCode, String retMessage) {
        this.retCode = retCode;
        this.retMessage = retMessage;
    }

    public static CountryEnum forEach_CountryEnum(int index) {
        // values()：枚举类自带的遍历方法
        CountryEnum[] countryEnum = CountryEnum.values();
        for (CountryEnum element : countryEnum) {
            if (index == element.getRetCode()) {
                return element;
            }
        }
        return null;
    }
}
